using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;



using OverredQQ.QQCore.Bean;
using OverredQQ.QQCore.Misc;

namespace OverredQQ.QQCore
{

    /// </author>
    /// <author>
    /// overred
    /// </author>


    public class OverredAdapter : QQCore.UpperLayerAdapterBase
    {
         private readonly OverredQQ.QQCore.Bean.QQUser user;
        public OverredQQ.QQCore.Bean.QQUser User
        {
            get
            {
                return user;
            }
        }

        public OverredQQ.QQCore.Misc.QQCache Cache
        {
            get
            {
                return Adapter.Cache;
            }
        }



        public OverredAdapter(uint uin, byte[] password, bool udp)
        {
            this.user = new OverredQQ.QQCore.Bean.QQUser(uin, password);
            this.user.Udp = udp;
        }

        public OverredAdapter(uint uin, string password, bool udp)
        {
            this.user = new OverredQQ.QQCore.Bean.QQUser(uin, password);
            this.user.Udp = udp;
        }



        #region Override-Methods
        public override void IMReceive_Normal0(
            OverredQQ.QQCore.Bean.ReceiveIMHeader header,
            OverredQQ.QQCore.Bean.NormalIMHeader normalHeader,
            OverredQQ.QQCore.Bean.NormalIM normalIM)
        {
            
        }

        public override void IMReceive_ClusterIM0(
            OverredQQ.QQCore.Bean.ReceiveIMHeader header,
            OverredQQ.QQCore.Bean.ClusterIM clusterIM)
        {
            
        }

        public override void GotAllFriendList()
        {

        }

        public override void GotAllFriendOnline()
        {
            //TODO;
        }

        public override void AdapterReady()
        {
            Adapter.GetFriendList();
            Adapter.SendGetUserInfoPacket(this.User.Uin);
            Adapter.SendChangeStatusPacket(false);
        }

        public override void SocketConnected()
        {
            Adapter.SendRequestLoginTokenPacket();
            //Adapter.SendRequestLoginTokenPacket();
        }

        public override void LoginReply_PasswordError(string errorMessage)
        {
           
        }

        public override void GotAllFriendGrouping()
        {
            //panel.Invoke(panel.RefreshAll, new object[] { Adapter.Cache });
        }

        public override void GroupNamesGot()
        {

        }

        public override void GroupNamesSent()
        {

        }

        public override void GetUserInfoReply(ContactInfo contactInfo)
        {
            Cache.SelfInfo = contactInfo;
        }

        public override void PacketParserFail(object sender, OverredQQ.QQCore.Network.Packet.PacketParseException e)
        {
           // MessageBox.Show(e.ToString());
        }

        public override void SocketError(object sender, Exception ex)
        {
            //MessageBox.Show(ex.ToString());
        }

        #endregion
    }


}
